# Contributor: Alex Yam <alex@alexyam.com>
# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Alex Yam <alex@alexyam.com>
pkgname=flint
pkgver=2.9.0
pkgrel=1
pkgdesc="C library in support of computations in number theory"
url="https://www.flintlib.org/"
# s390x: https://github.com/wbhart/flint2/issues/1184
arch="all !s390x"
license="LGPL-2.1-or-later"
makedepends="
	cmake
	gmp-dev
	libntl-dev
	mpfr-dev
	openblas-dev
	python3
	samurai
	"
subpackages="$pkgname-dev"
source="https://www.flintlib.org/flint-$pkgver.tar.gz
	fix-sdiv_qrnnd-test.patch"

build() {
	# Project uses cpu_set_t type extensively throughout the codebase
	# and sometimes without defining _GNU_SOURCE.
	# Patching all this seems too operose...
	export CFLAGS="$CFLAGS -D_GNU_SOURCE"

	cmake -G Ninja -B build \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DWITH_NTL=ON \
		-DBUILD_TESTING=ON
	cmake --build build
}

check() {
	ctest -j4 --output-on-failure --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
e213f0d5b4d03195357253593b2e0c2f04ef07b1cc24b302ad0e995f92aa9e0fa8beb1709db58ed1fff039ea88b0ce2acda3b6123f61dcf11852399b74a71364  flint-2.9.0.tar.gz
092f9b035167c80d6f862c7bda278effe3c8321a4a606be5375a17c381ce46d5f2135f747594f6ebdf761d3f11604b1da46eaa650cda9034be46c17e48fad4f9  fix-sdiv_qrnnd-test.patch
"
